import { useSelector, useDispatch } from "react-redux"



const View = () => {
    const dispatch = useDispatch()

    const { num } = useSelector((state:RootState) => ({
        num: state.handleNum.num
    }))
    const changeNum = () => {
        dispatch({ type: 'add2',val:10 })
    }
    const { sarr } = useSelector((state:RootState) => ({
        sarr: state.handleArr.sarr
    }))
    const changeArr = () => {
        dispatch({ type: 'sarrpush',val:100 })
    }
    return (
        <div className="home"> 
            <div>这是page1组件 </div>
            <p>{num}</p>
            <button onClick={changeNum}>按钮++</button>
            <p>{sarr}</p>
            <button onClick={changeArr}>按钮++</button>
        </div>
    )
}
export default View